<li class="property_attribute">
  <div>
    <%= property_attribute.label :presentation %>
    <%= property_attribute.autocomplete_field :presentation, autocomplete_property_attribute_presentation_admin_properties_path(:property_id => property_attribute.object.property.id), :class => "property_attribute_presentation", :maxlength => 35, :size => 16, :node_id => property_attribute.object.id %>

    <%= property_attribute.hidden_field :node_parent_id, :class => "property_attribute_parent_id", :size => 4 %>
    <%= property_attribute.hidden_field :node_next_id,   :class => "property_attribute_next_id", :size => 4 %>
    <%= property_attribute.hidden_field :node_prev_id,   :class => "property_attribute_prev_id", :size => 4 %>
    <%= property_attribute.hidden_field :node_id,        :class => "property_attribute_node_id", :size => 4, :value => property_attribute.object.id %>

    <%= property_attribute.fields_for :property_value do |property_value| %>
      <%= property_value.label :value %>
      <% if property_attribute.object.value_type == 'select' %>
        <%= property_value.select :value, options_from_collection_for_select(property_attribute.object.property_enum_values, :value, :value, "#{property_value.object.value}") %>
    
      <% elsif property_attribute.object.value_type == 'choice' %>
        <label>Ne&nbsp;<%= property_value.radio_button :value, "0", :value => "0", :checked => (true if property_value.object.value.to_s != "1") %></label>
        <label>Ano&nbsp;<%= property_value.radio_button :value, "1", :value => "1" %></label>
    
      <% else %>
        <%= property_value.autocomplete_field :value, autocomplete_property_value_value_admin_properties_path, :class => "property_value_value", :id => "#{dom_id(property_value.object, :property_value)}", :maxlength => 60, :size => 20 %>
        <%= property_value.collection_select :metric_id, Metric.all, :id, :presentation, {:include_blank => true}, {:id => dom_id(property_value.object, :metric)} %>

        <script type="text/javascript">
          $(document).ready(function(){
            $('#<%= "#{dom_id(property_value.object, :property_value)}"%>').bind('railsAutocomplete.select', function(event, data) {
              $('#<%= "#{dom_id(property_value.object, :metric)}" %>').val(data.item.metric_id);
              $('#<%= "#{dom_id(property_value.object, :property_value)}" %>').val(data.item.label.split(" {")[0]);
            });
          });
        </script>
      <% end %>
    <% end %>

    <span style="float: right;"><%= link_to_remove_fields("Smazat vlastnost", property_attribute, "property_attribute") %></span>
  </div>

  <% unless property_attribute.object.children.blank?  %>
    <ol>
      <% property_attribute.object.children.each do |pa| %>
        <%= property.fields_for :property_attributes, pa do |property_attribute| %>
          <%= render :partial => "property_attributes", :locals => {:property_attribute => property_attribute, :property => property} %>
        <% end %>
      <% end %>
    </ol>
  <% end %>
</li>